#include <iostream>
using namespace std;

/*
    【题目210】声明一个Shape基类，在此基础上派生出Rectangle类和Circle类，二者都有GetArea()函数计算对象的面积。
            使用Rectangle类创建一个派生类Square。
*/
class Shape
{
protected:
    double s;
    void show()
    {
        cout << "面积 = " << s << endl;
    }
};
// 矩形
class Rectangle : public Shape
{
public:
    void GetArea(double a, double b)
    {
        s = a * b;
        cout << "矩形面积 = ";
        show();
    }

private:
    double a, b;
};
// 圆形
class Circle : public Shape
{
public:
    void GetArea(double r)
    {
        s = 3.14 * r * r;
        cout << "圆形面积 = ";
        show();
    }

private:
    double r;
};
// 正方形
class Square : public Rectangle
{
public:
    void GetArea(double a)
    {
        Rectangle::GetArea(a, a);
    }
};

int main()
{
    Rectangle r;
    r.GetArea(3, 4);
    Circle c;
    c.GetArea(5);
    Square s;
    s.GetArea(5);
    return 0;
}